home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
OLE2BOOK.ZIP
/
CHAP11.ZIP
/
CHAP11
/
COSCHMOO
/
COSCHMOO.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-13
|
9KB
|
311 lines
/*
* COSCHMOO.H
* Component Schmoo Chapter 8
*
* Single include file that pulls in everything needed for other source
* files in the Schmoo application.
*
* Copyright (c)1993 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _COSCHMOO_H_
#define _COSCHMOO_H_
#include <windows.h>
#include <memory.h>
#include <ole2.h>
#include <ole2ver.h>
#include <bookguid.h>
#include <ipoly6.h>
//These include files reference DLLs that don't have extern "C" already
extern "C"
{
#include <commdlg.h>
}
#include <classlib.h>
#include "resource.h"
//COSCHMOO.CPP: Frame object that creates a main window
class __far CSchmooFrame : public CFrame
{
private:
HBITMAP m_hBmpLines[5]; //Menu item bitmaps
BOOL m_fInitialized; //CoInitialize work?
protected:
//Overridable for creating a CClient for this frame
virtual LPCClient CreateCClient(void);
//FRegisterAllClasses override unneccessary with Polyline DLL
virtual BOOL FPreShowInit(void);
virtual UINT CreateGizmos(void);
virtual LRESULT OnCommand(HWND, WPARAM, LPARAM);
virtual void OnDocumentDataChange(LPCDocument);
virtual void OnDocumentActivate(LPCDocument);
//New for this class
virtual void CreateLineMenu(void);
public:
CSchmooFrame(HINSTANCE, HINSTANCE, LPSTR, int);
virtual ~CSchmooFrame(void);
//Overrides
virtual BOOL FInit(LPFRAMEINIT);
virtual void UpdateMenus(HMENU, UINT);
virtual void UpdateGizmos(void);
//New for this class
virtual void CheckLineSelection(UINT);
};
typedef CSchmooFrame FAR * LPCSchmooFrame;
//CLIENT.CPP
/*
* The only reason we have a derived class here is to override
* CreateCDocument so we can create our own type as well as
* overriding NewDocument to perform one other piece of work once the
* document's been created.
*/
class __far CSchmooClient : public CClient
{
protected:
//Overridable for creating a new CDocument
virtual LPCDocument CreateCDocument();
public:
CSchmooClient(HINSTANCE);
virtual ~CSchmooClient(void);
virtual LPCDocument NewDocument(BOOL, LPCDocumentAdviseSink);
};
typedef CSchmooClient FAR * LPCSchmooClient;
//DOCUMENT.CPP
class __far CPolylineAdviseSink : public IPolylineAdviseSink6
{
private:
LPVOID m_pv; //Customizable structure
ULONG m_cRef;
LPUNKNOWN m_punkOuter; //Unknown for delegation
public:
CPolylineAdviseSink(LPVOID, LPUNKNOWN);
~CPolylineAdviseSink(void);
//IUnknown members
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//Advise members.
STDMETHODIMP_(void) OnPointChange(void);
STDMETHODIMP_(void) OnSizeChange(void);
STDMETHODIMP_(void) OnColorChange(void);
STDMETHODIMP_(void) OnLineStyleChange(void);
};
typedef CPolylineAdviseSink FAR * LPCPolylineAdviseSink;
/*
* The generic advisory interface. This object controls it's own
* lifetime and the document becomes a user of the object with
* the last reference count.
*/
class __far CImpIAdviseSink : public IAdviseSink
{
protected:
ULONG m_cRef; //Interface reference count.
LPVOID m_pObj; //Back pointer to the document
LPUNKNOWN m_punkOuter; //Unknown for delegation
public:
CImpIAdviseSink(LPVOID, LPUNKNOWN);
~CImpIAdviseSink(void);
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM);
STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
STDMETHODIMP_(void) OnRename(LPMONIKER);
STDMETHODIMP_(void) OnSave(void);
STDMETHODIMP_(void) OnClose(void);
};
//Constant ID for the window polyline that lives in a document window
#define ID_POLYLINE 10
class __far CSchmooDoc : public CDocument, public IUnknown
{
friend class CPolylineAdviseSink;
friend class CImpIAdviseSink;
//CHAPTER8MOD
//These need access to FQueryPasteFromData, FPasteFromData
friend class CDropTarget;
friend class CDropSource;
//End CHAPTER8MOD
protected:
UINT m_uPrevSize; //Last WM_SIZE wParam
//Interface we use on the Polyline Object
LPPOLYLINE m_pPL;
LPPERSISTSTORAGE m_pIPersistStorage;
//Interfaces we implement
LPPOLYLINEADVISESINK m_pPLAdv; //Polyline
LPADVISESINK m_pIAdviseSink; //Standard for OnDataChange
DWORD m_dwConn; //Advisory connection
ULONG m_cRef; //Document ref count
//CHAPTER8MOD
class CDropTarget FAR *m_pDropTarget; //Registered target.
BOOL m_fDragSource; //Drag-drop source==target
//End CHAPTER8MOD
protected:
virtual BOOL FMessageHook(HWND, UINT, WPARAM, LPARAM, LRESULT FAR *);
//CHAPTER8MOD
virtual BOOL FQueryPasteFromData(LPDATAOBJECT);
virtual BOOL FPasteFromData(LPDATAOBJECT);
LPDATAOBJECT TransferObjectCreate(void);
void DropSelectTargetWindow(void);
//End CHAPTER8MOD
public:
CSchmooDoc(HINSTANCE);
virtual ~CSchmooDoc(void);
//Since we implement multiple interfaces we need a controlling unknown
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
virtual BOOL FInit(LPDOCUMENTINIT);
virtual void Clear();
virtual UINT ULoad(BOOL, LPSTR);
virtual UINT USave(UINT, LPSTR);
virtual void Undo(void);
virtual BOOL FClip(HWND, BOOL);
virtual BOOL FQueryPaste(void);
virtual BOOL FPaste(HWND);
virtual COLORREF ColorSet(UINT, COLORREF);
virtual COLORREF ColorGet(UINT);
virtual UINT LineStyleSet(UINT);
virtual UINT LineStyleGet();
};
typedef CSchmooDoc FAR * LPCSchmooDoc;
//These color indices wrap the polyline definitions
#define DOCCOLOR_BACKGROUND POLYLINECOLOR_BACKGROUND
#define DOCCOLOR_LINE POLYLINECOLOR_LINE
//CHAPTER8MOD
//Drag-drop interfaces we need in the document
class __far CDropTarget : public IDropTarget
{
protected:
ULONG m_cRef; //Interface reference count.
LPCSchmooDoc m_pDoc; //Back pointer to the document
LPDATAOBJECT m_pIDataObject; //Data object from DragEnter
public:
CDropTarget(LPCSchmooDoc);
~CDropTarget(void);
//IDropTarget interface members
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
STDMETHODIMP DragEnter(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
STDMETHODIMP DragOver(DWORD, POINTL, LPDWORD);
STDMETHODIMP DragLeave(void);
STDMETHODIMP Drop(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
};
typedef CDropTarget FAR * LPCDropTarget;
class __far CDropSource : public IDropSource
{
protected:
ULONG m_cRef;